|
1
|
|
|
// jshint esversion: 8, -W030 |
|
2
|
|
|
|
|
3
|
|
|
/** global: appSettings */ |
|
4
|
|
|
const whois = require('../../common/whoisWrapper'), |
|
|
|
|
|
|
5
|
|
|
conversions = require('../../common/conversions'), |
|
|
|
|
|
|
6
|
|
|
fs = require('fs'), |
|
|
|
|
|
|
7
|
|
|
Papa = require('papaparse'), |
|
|
|
|
|
|
8
|
|
|
dt = require('datatables')(); |
|
|
|
|
|
|
9
|
|
|
|
|
10
|
|
|
const { |
|
11
|
|
|
ipcRenderer |
|
12
|
|
|
} = require('electron'); |
|
13
|
|
|
|
|
14
|
|
|
var bwaFileContents; |
|
15
|
|
|
|
|
16
|
|
|
/* |
|
17
|
|
|
ipcRenderer.on('bwa:analyser.tablegen', function() {...}); |
|
18
|
|
|
Generate analyser content table |
|
19
|
|
|
parameters |
|
20
|
|
|
event |
|
21
|
|
|
contents |
|
22
|
|
|
*/ |
|
23
|
|
|
ipcRenderer.on('bwa:analyser.tablegen', function(event, contents) { |
|
24
|
|
|
bwaFileContents = contents; |
|
25
|
|
|
showTable(); |
|
26
|
|
|
|
|
27
|
|
|
return; |
|
|
|
|
|
|
28
|
|
|
}); |
|
29
|
|
|
|
|
30
|
|
|
/* |
|
31
|
|
|
$('#bwaAnalyserButtonClose').click(function() {...}); |
|
32
|
|
|
Bulk whois analyser close button |
|
33
|
|
|
*/ |
|
34
|
|
|
$('#bwaAnalyserButtonClose').click(function() { |
|
35
|
|
|
ipcRenderer.send('app:debug', '#bwaAnalyserButtonClose clicked'); |
|
36
|
|
|
$('#bwaAnalyserModalClose').addClass('is-active'); |
|
37
|
|
|
|
|
38
|
|
|
return; |
|
|
|
|
|
|
39
|
|
|
}); |
|
40
|
|
|
|
|
41
|
|
|
/* |
|
42
|
|
|
$('#bwaAnalyserModalCloseButtonYes').click(function() {...}); |
|
43
|
|
|
bwa, close dialog confirm/yes |
|
44
|
|
|
*/ |
|
45
|
|
|
$('#bwaAnalyserModalCloseButtonYes').click(function() { |
|
46
|
|
|
$('#bwaAnalyser').addClass('is-hidden'); |
|
47
|
|
|
$('#bwaAnalyserModalClose').removeClass('is-active'); |
|
48
|
|
|
$('#bwaEntry').removeClass('is-hidden'); |
|
49
|
|
|
|
|
50
|
|
|
return; |
|
|
|
|
|
|
51
|
|
|
}); |
|
52
|
|
|
|
|
53
|
|
|
/* |
|
54
|
|
|
$('#bwaAnalyserModalCloseButtonNo').click(function() {...}); |
|
55
|
|
|
Bulk whois analyser close dialog cancel/no button |
|
56
|
|
|
*/ |
|
57
|
|
|
$('#bwaAnalyserModalCloseButtonNo').click(function() { |
|
58
|
|
|
$('#bwaAnalyserModalClose').removeClass('is-active'); |
|
59
|
|
|
|
|
60
|
|
|
return; |
|
|
|
|
|
|
61
|
|
|
}); |
|
62
|
|
|
|
|
63
|
|
|
/* |
|
64
|
|
|
showTable |
|
65
|
|
|
ipsum |
|
66
|
|
|
*/ |
|
67
|
|
|
function showTable() { |
|
68
|
|
|
var header = {}, |
|
69
|
|
|
body = {}; |
|
70
|
|
|
header.columns = Object.keys(bwaFileContents.data[0]); |
|
71
|
|
|
body.records = bwaFileContents.data; |
|
72
|
|
|
|
|
73
|
|
|
// Generate header column content |
|
74
|
|
|
header.content = '<tr>\n'; |
|
75
|
|
|
for (var column in header.columns) { |
|
|
|
|
|
|
76
|
|
|
header.content += '\t<th><abbr title="{0}">{1}</abbr></th>\n'.format(header.columns[column], getInitials(header.columns[column])); |
|
77
|
|
|
} |
|
78
|
|
|
header.content += '</tr>'; |
|
79
|
|
|
|
|
80
|
|
|
$('#bwaAnalyserTableThead').html(header.content); |
|
81
|
|
|
|
|
82
|
|
|
// Generate record fields |
|
83
|
|
|
body.content = ''; |
|
84
|
|
|
for (var record in body.records) { |
|
|
|
|
|
|
85
|
|
|
body.content += '<tr>\n'; |
|
86
|
|
|
|
|
87
|
|
|
for (var field in body.records[record]) { |
|
|
|
|
|
|
88
|
|
|
body.content += '\t<td>{0}</td>\n'.format(body.records[record][field]); |
|
89
|
|
|
} |
|
90
|
|
|
body.content += '</tr>\n'; |
|
91
|
|
|
} |
|
92
|
|
|
$('#bwaAnalyserTableTbody').html(body.content); |
|
93
|
|
|
|
|
94
|
|
|
body.table = $('#bwaAnalyserTable').dataTable({ |
|
95
|
|
|
'destroy': true |
|
96
|
|
|
}); |
|
97
|
|
|
|
|
98
|
|
|
|
|
99
|
|
|
$('#bwaFileinputconfirm').addClass('is-hidden'); |
|
100
|
|
|
$('#bwaAnalyser').removeClass('is-hidden'); |
|
101
|
|
|
//body.content.destroy(); |
|
102
|
|
|
|
|
103
|
|
|
return; |
|
|
|
|
|
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
/* |
|
107
|
|
|
getInitials |
|
108
|
|
|
ipsum |
|
109
|
|
|
parameters |
|
110
|
|
|
string |
|
111
|
|
|
threshold |
|
112
|
|
|
*/ |
|
113
|
|
|
function getInitials(string, threshold = 1) { |
|
114
|
|
|
var initials = string.match(/\b\w/g); |
|
115
|
|
|
|
|
116
|
|
|
initials = (initials.length > threshold) ? |
|
117
|
|
|
initials.join("").toString() : |
|
118
|
|
|
string.substring(0, threshold + 1); |
|
119
|
|
|
|
|
120
|
|
|
return initials; |
|
121
|
|
|
} |
|
122
|
|
|
|